//
//  DDDAdZYSdkBannerVC.m
//  DDDAdZYSdkDemo
//
//  Created by mu on 2020/9/11.
//  Copyright © 2020 summer. All rights reserved.
//

#import "DDDAdZYSdkBannerVC.h"
#import <DDDAdZYSdk/DDDAdZYSdk.h>

@interface DDDAdZYSdkBannerVC () <DDDAdZYBannerViewDelegate>
@property (nonatomic, strong) DDDAdZYBannerView *bannerView;
@end

@implementation DDDAdZYSdkBannerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSLog(@"%@",self.adId);
    NSLog(@"%@",self.number);
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.bannerView];
    [self.bannerView loadAdAndShow];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
//    self.bannerView = nil;
//    [self.bannerView removeFromSuperview];
}
- (void)dealloc {
    NSLog(@"%s",__func__);
}
#pragma mark-- DDDAdZYBannerViewDelegate
/// 广告加载成功
- (void)nativeExpressBannerAdViewDidLoad {
    NSLog(@"%s",__func__);
}

/// 广告加载失败
/// @param errorCode 错误码
- (void)nativeExpressBannerAdViewLoadFailWithError:(NSInteger )errorCode {
    NSLog(@"%s--%ld",__func__,errorCode);
}


/// 广告展现成功
- (void)nativeExpressBannerAdViewRenderSuccess {
    NSLog(@"%s",__func__);
}

/// 广告无法呈现
/// @param errorCode 错误码
- (void)nativeExpressBannerAdViewRenderFailWithError:(NSInteger)errorCode {
    NSLog(@"%s--%ld",__func__,errorCode);
}

/**
 有新的广告调用此方法
 */
- (void)nativeExpressBannerAdViewWillBecomVisible {
    NSLog(@"%s",__func__);
}

/// 点击广告时回调
- (void)nativeExpressBannerAdViewDidClick {
    NSLog(@"%s",__func__);
}

/// 此方法在关闭另一个控制器时调用
- (void)nativeExpressBannerAdViewDidCloseOtherController {
    NSLog(@"%s",__func__);
}


#pragma mark-- 懒加载
- (DDDAdZYBannerView *)bannerView {
    if (!_bannerView) {
        CGFloat width = [UIScreen mainScreen].bounds.size.width;
        CGFloat height = width / 6.4;
        _bannerView = [[DDDAdZYBannerView alloc]initWithFrame:CGRectMake(0.0, 100.0, width, height) adId:self.adId rootViewController:self];
        _bannerView.delegate = self;
        _bannerView.loadNumber = [self.number integerValue];
    }
    return _bannerView;
}


@end
